<template>
  <div class="app-container">

    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-form-item label="二级渠道名称" prop="name">
        <el-input v-model="form.name" placeholder="请输入二级渠道名称" />
      </el-form-item>
      <el-form-item label="联系人" prop="contactPerson">
        <el-input v-model="form.contactPerson" placeholder="请输入联系人" />
      </el-form-item>
      <el-form-item label="联系电话" prop="contactPhone">
        <el-input v-model="form.contactPhone" placeholder="请输入联系电话" />
      </el-form-item>
      <el-form-item label="微信号" prop="wechat">
        <el-input v-model="form.wechat" placeholder="请输入微信号" />
      </el-form-item>
      <el-form-item label="支付宝名字" prop="aliName">
        <el-input v-model="form.aliName" placeholder="请输入支付宝名字" />
      </el-form-item>
      <el-form-item label="支付宝账号" prop="aliAccount">
        <el-input v-model="form.aliAccount" placeholder="请输入支付宝账号" />
      </el-form-item>
      <el-form-item label="身份证号" prop="proveNumber">
        <el-input v-model="form.proveNumber" placeholder="请输入身份证号" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">申请修改</el-button>
      </el-form-item>
    </el-form>


  </div>
</template>

<script>
import { getChannel, updateChannel } from "@/api/system/channel";
export default {
  data() {
    return {
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        channelNumber: [
          { required: true, message: "渠道编号不能为空", trigger: "blur" }
        ],
        parentBusiness: [
          { required: true, message: "归属商务不能为空", trigger: "blur" }
        ],
        name: [
          { required: true, message: "渠道名称不能为空", trigger: "blur" }
        ],
        contactPerson: [
          { required: true, message: "联系人不能为空", trigger: "blur" }
        ],
        contactPhone: [
          { required: true, message: "联系方式不能为空", trigger: "blur" }
        ],
        wechat: [
          { required: true, message: "微信号不能为空", trigger: "blur" }
        ],
        managerAccount: [
          { required: true, message: "后台账号不能为空", trigger: "blur" }
        ],
        managerPwd: [
          { required: true, message: "后台账号密码不能为空", trigger: "blur" }
        ],
        aliName: [
          { required: true, message: "支付宝名字不能为空", trigger: "blur" }
        ],
        aliAccount: [
          { required: true, message: "支付宝账号不能为空", trigger: "blur" }
        ],
        proveNumber: [
          { required: true, message: "身份证号不能为空", trigger: "blur" }
        ],
        settle: [
          { required: true, message: "结算方式不能为空", trigger: "blur" }
        ],
        maxRegister: [
          { required: true, message: "总注册量限制不能为空", trigger: "blur" }
        ],
        createDate: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        createBy: [
          { required: true, message: "创建人不能为空", trigger: "blur" }
        ],
        status: [
          { required: true, message: "状态不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    console.log('state = %o',this.$store.state.user)
    if(this.$store.state.user.channel){
      getChannel(this.$store.state.user.channel.id).then(response => {
        this.form = response.data;
      });
    }else{
      this.msgError("您没有渠道账户，不应有此权限！");
      this.$router.go(-1);
      return
    }
  },
  methods: {
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateChannel(this.form).then(response => {
            if (response.code === 200) {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }
          });
        }
      });
    }
  }
};
</script>